package com.aya.transaction;

import com.aya.transaction.service.BlogNestedTransactionService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;

/**
 * 事物异常回滚
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringTransaction.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class NestedTransaction {

    @Resource
    BlogNestedTransactionService blogNestedTransactionService;

    @Test
    public void testSuccess() {
        blogNestedTransactionService.updateByIdSuccess("1", "transaction success", "2", "success");
    }

    @Test
    public void testFailure() {
        blogNestedTransactionService.updateByIdInnerFailure("1", "transaction success", "2", "not support failure");
    }

    /**
     *
     */
    @Test
    public void testCatcjFailure() {
        blogNestedTransactionService.updateByIdCatchFailure("1", "transaction success", "2", "not support failure");
    }

}
